﻿using System;
using System.Data;
using System.Configuration;
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;
using LdExpress;
using System.IO;
using System.Globalization;

public partial class _Default : System.Web.UI.Page
{
    public string ContainerPage = "./Prices.SerArea.aspx";
    public string strCondition = "";
    public int NumOfItemsPerPage = 25;
    public string strPager = "";
    public string strIDs = "";
    public string strError = "";
    public string strMess = "";
    public int nPermissions = 0;
    public string strPortToName = "";
    public string strPortFromName = "";
    public int nPage = 1;
    public string strAlphaBet = "";
    public string strPageID = "page_number";
    public string strLetter = "letter";
    string strChar = "";
    string strExcluded = "";
    public string strPartQuery = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Request.QueryString[strLetter] != null)
            {
                strChar = Request.QueryString[strLetter].ToString();
                strCondition = " AND CarrName like '" + strChar + "%'";
            }
        }
        catch
        {
            strChar = "";
        }
        try
        {

            if (Request.QueryString[strPageID] != null)
                nPage = int.Parse(Request.QueryString[strPageID]);
        }
        catch
        {
            nPage = 1;
        }
        if (nPage <= 0) nPage = 1;

        if (Session["logined_id"] != null)
        {
            if (Session["CheckArea"] != "") nPermissions = int.Parse(Session["CheckArea"].ToString());
            if (nPermissions <= 0) Response.Redirect("Login.aspx");
        }
        else
            Response.Redirect("Login.aspx");
        if (Session["AreaPortFromName"] == null)
            Session["AreaPortFromName"] = "";
        if (Session["AreaPortFromID"] == null)
            Session["AreaPortFromID"] = 0;
        if (Session["AreaPortToName"] == null)
            Session["AreaPortToName"] = "";
        if (Session["AreaPortToID"] == null)
            Session["AreaPortToID"] = 0;
        if (Session["SerArea"] == null)
            Session["SerArea"] = "";
        if (Session["SerCountry"] == null)
            Session["SerCountry"] = "";
        if (Session["PriceTimeUpdate"] == null)
            Session["PriceTimeUpdate"] = "1500";
        if ((Request.QueryString["PortToID"] != null) || (Request.QueryString["PortFromID"] != null))
            CommonFunctions.BuildAphabetSearch(Request, ContainerPage, strLetter, strChar, strExcluded, out strAlphaBet);
        if (Request.QueryString["PortToID"] != null)
            Session["AreaPortToID"] = Request.QueryString["PortToID"].ToString();
        if (Request.QueryString["PortFromID"] != null)
            Session["AreaPortFromID"] = Request.QueryString["PortFromID"].ToString();
        if (!Page.IsPostBack)
        {
            CommonFunctions.GetAllQueryString(Request, "", "id", out strPartQuery);
            txtPortFromSearch.Text = Session["AreaPortFromName"].ToString();
            txtPortToSearch.Text = Session["AreaPortToName"].ToString();
            txtSerArea.Text = Session["SerArea"].ToString();
            txtCountry.Text = Session["SerCountry"].ToString();
            drPriceUpdateTime.SelectedValue = Session["PriceTimeUpdate"].ToString();
            if (Request.QueryString["action"] == "delete" && nPermissions > 7)
            {
                Prices obj = new Prices();
                obj.ID = long.Parse(Request.QueryString["ID"]);
                obj.Delete(GV.cn, GV.trans);
                UserObjectsLog.SaveObjectActionLog(long.Parse(Session["logined_id"].ToString()), "Prices", "Delete", GV.cn, GV.trans);
                Response.Redirect("Prices.aspx" + ((Request.QueryString["page_number"] != null && Request.QueryString["page_number"].ToString() != "") ? "?page_number=" + Request.QueryString["page_number"].ToString() : ""));
            }
            if (Request.QueryString["action"] == "public")
            {
                Prices objPrice = new Prices();
                objPrice.ID = long.Parse(Request.QueryString["ID"].ToString());
                objPrice.LoadExtention(GV.cn, GV.trans);
                string tempDt = "";
                string tempRate = "";
                if (objPrice.DC20.Length > 10)
                {
                    //tempDt = objPrice.DC20.Substring(objPrice.DC20.Length - 10).Trim();
                    tempDt = objPrice.DC20.Split('_')[1].ToString();
                    tempDt = tempDt.Substring(tempDt.Length - 10).Trim();
                    tempRate = objPrice.DC20.Split('_')[0].ToString();
                    GoodPricesNotice.PublicGoodPriceNotice(objPrice, tempDt, tempRate, "20'DC");
                }
                if (objPrice.DC40.Length > 10)
                {
                    //tempDt = objPrice.DC40.Substring(objPrice.DC40.Length - 10).Trim();
                    tempDt = objPrice.DC40.Split('_')[1].ToString();
                    tempDt = tempDt.Substring(tempDt.Length - 10).Trim();
                    tempRate = objPrice.DC40.Split('_')[0].ToString();
                    GoodPricesNotice.PublicGoodPriceNotice(objPrice, tempDt, tempRate, "40'DC");
                }
                if (objPrice.HC40.Length > 10)
                {
                    //tempDt = objPrice.HC40.Substring(objPrice.HC40.Length - 10).Trim();
                    tempDt = objPrice.HC40.Split('_')[1].ToString();
                    tempDt = tempDt.Substring(tempDt.Length - 10).Trim();
                    tempRate = objPrice.HC40.Split('_')[0].ToString();
                    Response.Write("tempDt=" + tempDt + "  tempRate=" + tempRate);
                    GoodPricesNotice.PublicGoodPriceNotice(objPrice, tempDt, tempRate, "40'HC");
                }
                if (objPrice.RF20.Length > 10)
                {
                    //tempDt = objPrice.RF20.Substring(objPrice.RF20.Length - 10).Trim();
                    tempDt = objPrice.RF20.Split('_')[1].ToString();
                    tempDt = tempDt.Substring(tempDt.Length - 10).Trim();
                    tempRate = objPrice.RF20.Split('_')[0].ToString();
                    GoodPricesNotice.PublicGoodPriceNotice(objPrice, tempDt, tempRate, "20'RF");
                }
                if (objPrice.RF40.Length > 10)
                {
                    //tempDt = objPrice.RF40.Substring(objPrice.RF40.Length - 10).Trim();
                    tempDt = objPrice.RF40.Split('_')[1].ToString();
                    tempDt = tempDt.Substring(tempDt.Length - 10).Trim();
                    tempRate = objPrice.RF40.Split('_')[0].ToString();
                    GoodPricesNotice.PublicGoodPriceNotice(objPrice, tempDt, tempRate, "40'RF");
                }
                string extQueryString = "";
                if (int.Parse(Session["AreaPortToID"].ToString()) > 0)
                    extQueryString = "?PortToID=" + Session["AreaPortToID"].ToString();
                else if (int.Parse(Session["AreaPortFromID"].ToString()) > 0)
                    extQueryString = "?PortToID=" + Session["AreaPortFromID"].ToString();

                Response.Redirect("Prices.SerArea.aspx" + extQueryString);
            }
            if ((Request.QueryString["PortToID"] != null) || (Request.QueryString["PortFromID"] != null))
            {
                #region Build List
                int nNumOfPages = 0;

                DataTable dtList;
                BuildList(NumOfItemsPerPage, nPage, out nNumOfPages, out dtList, GV.cn, GV.trans);
                if (nPage > nNumOfPages) nPage = 1;

                rptData.DataSource = dtList;
                rptData.DataBind();
                #endregion
                #region Build Pager
                CommonFunctions.BuildPager(Request, nNumOfPages, nPage, strPageID, ContainerPage, out strPager);
                #endregion

            }
        }

    }
    protected void btnBack_Click(object sender, EventArgs e)
    {

    }
    private void BuildList(int NumOfItemsPerPage, int PageNo, out int nNumOfPages, out DataTable dtList, MySqlConnection cn, MySqlTransaction trans)
    {
        DataSet ds = null;
        dtList = new DataTable();
        dtList.Columns.Add("ID");
        dtList.Columns.Add("Sort");
        dtList.Columns.Add("Index");
        dtList.Columns.Add("CarrID");
        dtList.Columns.Add("PortTo");
        dtList.Columns.Add("PortFrom");
        dtList.Columns.Add("SerArea");
        dtList.Columns.Add("DC20");
        dtList.Columns.Add("DC40");
        dtList.Columns.Add("HC40");
        dtList.Columns.Add("CONT45");
        dtList.Columns.Add("RF20");
        dtList.Columns.Add("RF40");
        //dtList.Columns.Add("TSPort");
        //dtList.Columns.Add("Sailing");
        //dtList.Columns.Add("TT");
        //dtList.Columns.Add("Import");
        dtList.Columns.Add("Validity");
        dtList.Columns.Add("Description");
        dtList.Columns.Add("User");
        dtList.Columns.Add("LastUpdate");
        dtList.Columns.Add("Action");
        //OTFL
        dtList.Columns.Add("OT20");
        dtList.Columns.Add("OT40");
        dtList.Columns.Add("FL20");
        dtList.Columns.Add("FL40");
        dtList.Columns.Add("ValidityOTFL");
        dtList.Columns.Add("DescriptionOTFL");
        //Get List by SoIDs
        nNumOfPages = 0;

        if (int.Parse(Session["PriceTimeUpdate"].ToString()) > 0)
        {
            double addDay = double.Parse(Session["PriceTimeUpdate"].ToString());
            DateTime dtFrom, dtTo;
            if (addDay <= 90)
            {
                dtFrom = DateTime.Now.AddDays(-addDay);
                strCondition += " AND tbl_prices.LastUpdate >='" + dtFrom.ToString("yyyy-MM-dd") + "'";
            }
            else
            {
                DateTime dtNow = DateTime.Now;
                string strYear = dtNow.Year.ToString();
                string strMonth = dtNow.Month.ToString();
                string strdtFrom = "";
                string strdtTo = dtNow.ToString("yyyy-MM-dd");
                if (addDay == 500)// 1 --> now
                {
                    strdtFrom = strYear + "-" + strMonth + "-1";
                    strCondition += " AND tbl_prices.LastUpdate >='" + strdtFrom + "' AND tbl_prices.LastUpdate <='" + strdtTo + "'";
                }
                else if (addDay == 1000)  //15 --> now
                {
                    strdtFrom = strYear + "-" + strMonth + "-15";
                    strCondition += " AND tbl_prices.LastUpdate >='" + strdtFrom + "' AND tbl_prices.LastUpdate <='" + strdtTo + "'";
                }
                else if (addDay == 1500)  //All quote --> now
                {
                    strCondition += " AND (DC20 <> '' OR DC40 <>'' OR HC40<>'' OR RF20<>'' OR RF40<>'') ";
                }
            }

        }
        if (Session["AreaPortToID"] != null && int.Parse(Session["AreaPortToID"].ToString()) > 0)
        {
            strCondition += " and PortToID=" + Session["AreaPortToID"].ToString();
            if (Session["SerArea"].ToString().Length > 0)
            {
                if (Session["SerCountry"].ToString().Length > 0)
                {
                    strCondition += " HAVING (PODSER='" + DBModule.RefineString(Session["SerArea"].ToString()) + "'" +
                        " AND  PODCountry='" + DBModule.RefineString(Session["SerCountry"].ToString()) + "')";
                }
                else
                    strCondition += " HAVING PODSER='" + DBModule.RefineString(Session["SerArea"].ToString()) + "'";
            }
            else
            {
                if (Session["SerCountry"].ToString().Length > 0)
                    strCondition += " HAVING PODCountry='" + DBModule.RefineString(Session["SerCountry"].ToString()) + "'";
            }
        }
        if (Session["AreaPortFromID"] != null && int.Parse(Session["AreaPortFromID"].ToString()) > 0)
        {
            strCondition += " and PortFromID=" + Session["AreaPortFromID"].ToString();
            if (Session["SerArea"].ToString().Length > 0)
            {
                if (Session["SerCountry"].ToString().Length > 0)
                    strCondition += " HAVING (POLSER='" + DBModule.RefineString(Session["SerArea"].ToString()) + "'" +
                     " AND POLCountry='" + DBModule.RefineString(Session["SerCountry"].ToString()) + "')";
                else
                    strCondition += " HAVING POLSER='" + DBModule.RefineString(Session["SerArea"].ToString()) + "'";
            }
            else
            {
                if (Session["SerCountry"].ToString().Length > 0)
                    strCondition += " HAVING POLCountry='" + DBModule.RefineString(Session["SerCountry"].ToString()) + "'";
            }

        }


        if (strCondition == "") strCondition = "All";
        Prices obj = new Prices();


        Prices.GetListSerArea(strCondition, "LastUpdate Desc, CarrName Asc", NumOfItemsPerPage, PageNo, out nNumOfPages, out ds, GV.cn, GV.trans);

        if (ds != null && ds.Tables[0].Rows.Count > 0)
        {
            btnsave.Visible = true;
        }

        string strAllQueryString = "";

        foreach (string strKey in Request.QueryString.AllKeys)
        {
            if (strKey != null)
            {
                if ((strKey.ToLower() != "action") && (strKey.ToLower() != "id"))
                    strAllQueryString = strAllQueryString + "&" + strKey + "=" + Request.QueryString[strKey].ToString();
            }
        }

        if (strAllQueryString.Length >= 1)
            strAllQueryString = strAllQueryString.Substring(1);

        if (ds != null)
        {
            int count = 0;
            if (Request.QueryString["page_number"] != null && Request.QueryString["page_number"].ToString() != "")
            {
                int pagenumber = 1;
                try
                {
                    pagenumber = int.Parse(Request.QueryString["page_number"]);
                    count = NumOfItemsPerPage * (pagenumber - 1);
                }
                catch { count = 0; }
            }
            DataSet objds = null;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                objds = new DataSet();

                count++;
                string strSTT = dr["Sort"].ToString();
                string strIndex = count.ToString();
                string strCarrName = "";
                string CarrName = "";
                string strUser = AdminUser.GetUserNameByID(dr["userid"].ToString(), GV.cn, GV.trans);
                string sqlCommand = "select Name from tbl_carrs where id =" + dr["CarrID"].ToString() + " limit 0,1;";
                objds = DBModule.ExecuteQuery(sqlCommand, GV.cn, GV.trans);
                if (objds.Tables[0].Rows.Count > 0)
                {
                    strCarrName = "<a href=\"#\" ID=\"shedule" + dr["CarrID"].ToString() + "\" onmouseover=\"viewSchedules(" + dr["PortToID"].ToString() + "," + dr["PortFromID"].ToString() + "," + dr["CarrID"].ToString() + ");\">" + objds.Tables[0].Rows[0]["Name"].ToString() + "</a>";
                    CarrName = objds.Tables[0].Rows[0]["Name"].ToString();
                }

                string strPortTo = "";
                sqlCommand = "select Name from tbl_ports where ID =" + dr["PortToID"].ToString() + " limit 0,1;";
                objds = DBModule.ExecuteQuery(sqlCommand, GV.cn, GV.trans);
                if (objds.Tables[0].Rows.Count > 0)
                    strPortTo = objds.Tables[0].Rows[0]["Name"].ToString();

                string strPortFrom = "";
                sqlCommand = "select Name from tbl_ports where id =" + dr["PortFromID"].ToString() + " limit 0,1;";
                objds = DBModule.ExecuteQuery(sqlCommand, GV.cn, GV.trans);
                if (objds.Tables[0].Rows.Count > 0)
                    strPortFrom = objds.Tables[0].Rows[0]["Name"].ToString();
                string SerArea = "";
                if (Request.QueryString["PortToID"] != null)
                    SerArea = dr["PODSER"].ToString();//Hang xuat khau
                else if (Request.QueryString["PortFromID"] != null)
                    SerArea = dr["POLSER"].ToString();//Hang nhap khau

                string strID = dr["ID"].ToString();
                string strDC20 = dr["DC20"].ToString();
                string strDC40 = dr["DC40"].ToString();
                string strHC40 = dr["HC40"].ToString();
                string strCONT45 = dr["CONT45"].ToString();
                string strRF20 = dr["RF20"].ToString();
                string strRF40 = dr["RF40"].ToString();
                //string strTSPort = dr["TSPort"].ToString();
                //string strSailing = dr["Sailing"].ToString();
                //string strTT = dr["TT"].ToString();
                //string strImport = dr["Import"].ToString();
                string strValidity = dr["Validity"].ToString();
                string strDescription = dr["Description"].ToString();
                string OT20 = dr["OT20"].ToString();
                string OT40 = dr["OT40"].ToString();
                string FL20 = dr["FL20"].ToString();
                string FL40 = dr["FL40"].ToString();
                string ValidityOTFL = dr["ValidityOTFL"].ToString();
                string DescriptionOTFL = dr["DescriptionOTFL"].ToString();
                string strLastUpdate = "";
                //if (dr["LastUpdate"].ToString() != "") strLastUpdate = "<font color=\"#0000ff\">" + DateTime.Parse(dr["LastUpdate"].ToString()).ToString("ddMMyyyy") + "</font>";
                if (dr["LastUpdate"].ToString() != "")
                    strLastUpdate = DateTime.Parse(dr["LastUpdate"].ToString()).ToString("ddMMyyyy");
                string strAction = "";
                string strTemp = "";
                strTemp = dr["CarrID"].ToString();
                strTemp = strTemp.Replace("'", "\\'");
                bool isPublic = false;
                if (nPermissions >= 3)
                {
                    //strAction = "<a href=\"Prices.aspx?id=" + dr["ID"].ToString() + strPartQuery.Replace("?", "&") + "\">Edit</a>";
                    strAction = "<div class=\"changed\">";
                    //get public

                    //if (dr["LastUpdate"].ToString().Length > 0)
                    //{
                    //    DateTime dtLst = DateTime.Parse(dr["LastUpdate"].ToString());
                    //    if (dtLst.AddDays(7) >= DateTime.Now)
                    //    {
                    //        strAction = "<a href=\"javascript:doPublic('" + System.Web.HttpUtility.HtmlEncode(dr["ID"].ToString()) + "','" + System.Web.HttpUtility.HtmlEncode(strTemp) + "')\">Public</a>";
                    //        isPublic = true;
                    //    }
                    //}
                    if ((Request.QueryString["PortToID"] != null) && (Request.QueryString["PortFromID"] != null))
                    {
                        if (isPublic) strAction += " - ";
                        strAction += "<a href=\"Schedules.aspx?PortToID=" + Request.QueryString["PortToID"].ToString() + "&PortFromID=" + Request.QueryString["PortFromID"].ToString() + "&CarrName=" + CarrName + "\"  target=\"_blank\" >Schedules</a>";
                    }
                }
                if (nPermissions > 7)
                {
                    if (isPublic) strAction += " - ";
                    strAction += "<a href=\"javascript:doDelete('" + System.Web.HttpUtility.HtmlEncode(dr["ID"].ToString()) + "','" + System.Web.HttpUtility.HtmlEncode(strTemp) + "')\">Delete</a>";
                }
                //strEditProfile = "<a href=\"../DangKyCVC/ThongTinChungDKCVC.aspx?DangKyCVCID=" + dr["ID"].ToString() + "\">Sửa</a>";
                strAction += "</div>";
                //string[] strValues = new string[] { strID, strSTT, strIndex, strCarrName, strPortTo, strPortFrom, strDC20, strDC40, strHC40, strRF20, strRF40, strTSPort, strSailing, strTT, strImport, strValidity, strDescription, strUser, strLastUpdate, strAction };
                string[] strValues = new string[] { strID, strSTT, strIndex, strCarrName, strPortTo, strPortFrom, SerArea, strDC20, strDC40, strHC40, strCONT45, strRF20, strRF40, strValidity, strDescription, strUser, strLastUpdate, strAction,
                 OT20,OT40,FL20,FL40,ValidityOTFL,DescriptionOTFL };
                dtList.Rows.Add(strValues);
            }
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        if (txtPortToSearch.Text.Trim().Length == 0 && txtPortFromSearch.Text.Trim().Length == 0)
        {
            lblerror.Text = "Bạn phải chọn POL hoặc POD.";
            return;
        }
        if (txtPortToSearch.Text.Trim().Length > 0 && txtPortFromSearch.Text.Trim().Length > 0)
        {
            lblerror.Text = "Bạn chỉ được chọn POL hoặc POD.";
            return;
        }

        Prices obj = new Prices();
        string sqlCommand = "";
        DataSet ds = null;
        Session["AreaPortToName"] = "";
        Session["AreaPortToID"] = 0;
        Session["AreaPortFromName"] = "";
        Session["AreaPortFromID"] = 0;
        Session["SerArea"] = "";
        Session["SerCountry"] = "";
        if (txtPortToSearch.Text.Trim().Length > 0)
        {
            sqlCommand = "select Name,ID from tbl_ports where name ='" + DBModule.RefineString(txtPortToSearch.Text.Trim()) + "' limit 0,1;";
            ds = DBModule.ExecuteQuery(sqlCommand, GV.cn, GV.trans);
            if (ds.Tables[0].Rows.Count > 0)
            {
                strPortToName = ds.Tables[0].Rows[0]["Name"].ToString();
                obj.PortToID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                Session["AreaPortToName"] = strPortToName;
                Session["AreaPortToID"] = obj.PortToID;
            }
            else
                Session["AreaPortToName"] = "";
        }
        if (txtPortFromSearch.Text.Trim().Length > 0)
        {
            sqlCommand = "select Name,ID from tbl_ports where name ='" + DBModule.RefineString(txtPortFromSearch.Text.Trim()) + "' limit 0,1;";
            ds = DBModule.ExecuteQuery(sqlCommand, GV.cn, GV.trans);
            if (ds.Tables[0].Rows.Count > 0)
            {
                strPortFromName = ds.Tables[0].Rows[0]["Name"].ToString();
                obj.PortFromID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                Session["AreaPortFromName"] = strPortFromName;
                Session["AreaPortFromID"] = obj.PortFromID;
            }
            else
                Session["AreaPortFromName"] = "";
        }

        if (txtSerArea.Text.Length > 0)
        {
            Session["SerArea"] = txtSerArea.Text;
        }
        if (txtCountry.Text.Length > 0)
        {
            Session["SerCountry"] = txtCountry.Text;
        }
        string strRedirect = "Prices.SerArea.aspx?";
        if (txtPortToSearch.Text.Trim().Length > 0)
            strRedirect += "PortToID=" + obj.PortToID;
        else if (txtPortFromSearch.Text.Trim().Length > 0)
            strRedirect += "PortFromID=" + obj.PortFromID;
        strRedirect += ((Request.QueryString["page_number"] != null && Request.QueryString["page_number"].ToString() != "") ? "&page_number=" + Request.QueryString["page_number"].ToString() : "");
        Response.Redirect(strRedirect);

    }

    protected void drPriceUpdateTime_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["PriceTimeUpdate"] = drPriceUpdateTime.SelectedValue;
        if ((Request.QueryString["PortToID"] != null) || (Request.QueryString["PortFromID"] != null))
        {
            #region Build List
            int nNumOfPages = 0;

            DataTable dtList;
            BuildList(NumOfItemsPerPage, nPage, out nNumOfPages, out dtList, GV.cn, GV.trans);
            if (nPage > nNumOfPages) nPage = 1;

            rptData.DataSource = dtList;
            rptData.DataBind();
            #endregion
            #region Build Pager
            CommonFunctions.BuildPager(Request, nNumOfPages, nPage, strPageID, ContainerPage, out strPager);
            #endregion
        }
    }
    #region Quang
    public string GetCellTitle(object inputstring)
    {
        string title = "";
        if (inputstring != null && !string.IsNullOrEmpty(inputstring.ToString()))
        {
            string[] arrUpdate = inputstring.ToString().Split('_');
            if (arrUpdate.Length > 1)
                title = arrUpdate[1];
        }
        return title;
    }
    public string GetCellClass(object inputstring)
    {
        string className = "";
        if (inputstring != null && !string.IsNullOrEmpty(inputstring.ToString()))
        {
            string[] arrUpdate = inputstring.ToString().Split('_');
            if (arrUpdate.Length > 1)
            {
                if (arrUpdate[1].Length > 10)
                {
                    string tempDt = arrUpdate[1].Substring(arrUpdate[1].Length - 10).Trim();
                    try
                    {
                        DateTime dt = DateTime.ParseExact(tempDt, "dd-MM-yyyy", CultureInfo.InvariantCulture);
                        if (dt.AddDays(7) >= DateTime.Now)
                            className = "has-value-lastweek";
                        else if (dt.AddDays(14) >= DateTime.Now && dt.AddDays(7) < DateTime.Now)
                            className = "has-value-last2week";
                        else
                            className = "has-value";
                    }
                    catch
                    {
                        className = "has-value";
                    }
                }
            }
        }
        return className;
    }

    public string GetCellValue(object inputstring, bool emptyIfNull = false)
    {
        string cellvalue = !emptyIfNull ? "No check" : "";
        if (inputstring != null && !string.IsNullOrEmpty(inputstring.ToString()))
        {
            string[] arrUpdate = inputstring.ToString().Split('_');
            cellvalue = arrUpdate[0];
        }
        return cellvalue;
    }

    #endregion

}
